<?php defined('SYSPATH') or die();?>
<!doctype html>
<html>
<head>

    <meta charset="utf-8">
<title>添加/修改</title>
    {template 'stourtravel/public/public_min_js'}
    {php echo Common::getCss('style.css,base.css,base2.css,base_new.css'); }
    {php echo Common::getScript("uploadify/jquery.uploadify.min.js,product_add.js,choose.js,imageup.js"); }
    {php echo Common::getCss('uploadify.css','js/uploadify/'); }

</head>

<body>
	<table class="content-tab">
    <tr>
    <td width="119px" class="content-lt-td"  valign="top">
     {template 'stourtravel/public/leftnav'}
    <!--右侧内容区-->
    </td>
     <td valign="top" class="content-rt-td ">

          <form method="post" name="product_frm" id="product_frm">
          <div class="manage-nr">
          	<div class="cfg-header-bar">
          		<a href="javascript:;" class="fr btn btn-primary radius mt-6 mr-10" onclick="window.location.reload()">刷新</a>
          	</div>
            <!--基础信息开始-->
            <div class="product-add-div">
                <ul class="info-item-block">
                	<li>
                		<span class="item-hd">等级名称：</span>
                		<div class="item-bd">
                			<input type="text" name="title" class="input-text w150"  value="{$info['title']}" />
                		</div>
                	</li>
                	<li>
                		<span class="item-hd">推广订单数量区间：</span>
                		<div class="item-bd">
                			<input type="text" name="min_order_num" class="input-text w60" value="{$info['min_order_num']}" />
                          	<span class="lh-30 mr-5 ml-5">~</span>
                          	<input type="text" name="max_order_num" class="input-text w60" value="{$info['max_order_num']}" />
                		</div>
                	</li>
                	<li>
                		<span class="item-hd">积分策略：</span>
                		<div class="item-bd">
                			<a href="javascript:;" class="fl btn btn-primary radius size-S mt-3" id="set_jifen_btn">选择</a>
                            <div class="save-value-div mt-2 ml-10" id="jifen_con">
                                {if !empty($jifen)}
                                <span title="{$jifen['title']}"><s onclick="$(this).parent('span').remove()"></s>{$jifen['title']}<input type="hidden" name="jifen_id" value="{$jifen['id']}"></span>
                                {/if}
                            </div>
                            <span class="fl lh-30 c-999">*请为不同的分销商等级选择不同的积分策略。</span>
                		</div>
                	</li>
                </ul>  	
                <div class="clear clearfix pt-20 pb-20">
                    <a class="btn btn-primary radius size-L ml-115" id="btn_save" href="javascript:;">保存</a>
                </div>

          	</div>
              <input type="hidden" name="id" id="rankid" value="{$info['id']}"/>
        </form>
    </td>
    </tr>
    </table>

	<script>

	$(document).ready(function() {

        $("#set_jifen_btn").click(function () {
            var params = {loadCallback: chooseJifen, loadWindow: window};
            var url = SITEURL + "fenxiao/admin/rank/dialog_jifen"
            ST.Util.showBox('选择产品', url, '600', '430', null, null, document, params);
        });


        //保存
        $("#btn_save").click(function () {

            var title = $("input[name=title]").val();

            //验证名称
            if (title == '') {
                ST.Util.showMsg('请填写标题', 5, 2000);
            }
            else {
                $.ajaxform({
                    url: SITEURL + "fenxiao/admin/rank/ajax_save",
                    method: "POST",
                    isUpload: true,
                    form: "#product_frm",
                    dataType: "JSON",
                    success: function (data) {
                        if (data.status) {
                            if (data.productid != null) {
                                $("#rankid").val(data.id);
                            }
                            ST.Util.showMsg('保存成功!', '4', 2000);
                        }
                    }
                });
            }

        })

        //选择积分策略
        function chooseJifen(data)
        {
            var html='<span  title="'+data.title+'"><s onclick="$(this).parent(\'span\').remove()"></s>'+data.title+'<input type="hidden" name="jifen_id" value="'+data['id']+'"/>';
            $("#jifen_con").html(html);
        }

    });



    </script>

</body>
</html>
